﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityComponentSystem.Framework;
using ECS.Demos.Tetris.Systems;
using ECS.Demos.Tetris.Components;
using EntityComponentSystem.Framework.Math;

namespace ECS.Demos.Tetris.Behavoirs
{
    
    public class DrawSpriteBehavior : Behavior<IRenderSystem>
    {
        public DrawSpriteBehavior() : base("rendersystem", "drawsprite") { }
        protected override Action GetEntityBehavior(IRenderSystem system, GameEngine ge, int entity)
        {
            var position = ge.GetComponent(entity, "position");
            var size = ge.GetComponent(entity, "size");
            var texture = ge.GetComponent(entity, "texture");
            var color = ge.GetComponent(entity, "color");

            return new Action(() =>
            {
                system.DrawTexture(texture["name"], position["x"], position["y"], size["width"], size["height"], color.ToColorEx());
            });
        }
    }
}
